import 'dart:io';

import 'package:flutter/widgets.dart';
import 'package:full_display/unit/asset_utils/asset_utils.dart';
import 'package:full_display/unit/screen/screen_utility.dart';

class ItemSelectImage extends StatelessWidget {
  final List<String> imageList;
  final int index;
  final Function addImageCallBack;

  const ItemSelectImage(
      {Key? key,
      required this.index,
      required this.imageList,
      required this.addImageCallBack})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return imageList[index].isEmpty
        ? GestureDetector(
            behavior: HitTestBehavior.opaque,
            child: SizedBox(
              width: 64.0.W,
              height: 64.0.H,
              child: Image.asset(AssetUtils.getAssetImage("icon_select_image")),
            ),
            onTap: () {
              addImageCallBack.call();
            },
          )
        : SizedBox(
            width: 64.0.W,
            height: 64.0.H,
            child: Image.file(
              File(imageList[index]),
              fit: BoxFit.cover,
            ),
          );
  }
}
